package com.summer.framework.system.controller;

import com.summer.framework.base.result.Result;
import com.summer.framework.base.result.ResultUtil;
import com.summer.framework.base.result.SummerPage;
import com.summer.framework.system.controller.dto.UserInfoDTO;
import com.summer.framework.system.controller.query.UserInfoQuery;
import com.summer.framework.system.service.UserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户信息
 * @author Ice
 * @since 2025-09-16
 */
@RestController
@RequestMapping("/userInfo")
@RequiredArgsConstructor
public class UserInfoController {

    private final UserInfoService service;

    /**
     * 分页查询
     */
    @PostMapping("/page")
    public Result<SummerPage<UserInfoDTO>> page(@RequestBody UserInfoQuery query) {
        return ResultUtil.success(service.page(query));
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result<String> save(@RequestBody UserInfoDTO dto) {
        service.saveUser(dto);
        return ResultUtil.success();
    }

}
